package cn.jetpiece.cloud.joss.sdk.core.oss.model;

import cn.jetpiece.cloud.joss.sdk.core.oss.model.enums.AclEnum;
import cn.jetpiece.cloud.joss.sdk.core.oss.model.enums.PutObjectModeEnum;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

/**
 * @author XuJZ
 * @date 2020/9/10
 */

public class PutObject {

    /**
     * 上传对象模式
     *
     * @see PutObjectModeEnum
     */
    private Integer model = 1;

    /**
     * 桶
     */
    private String bucketName;

    /**
     * 数据权限(1:私有,2:公共可读),没传使用桶策略,Minio对象无法设置
     *
     * @see AclEnum
     */
    private Integer acl;

    public Integer getModel() {
        return model;
    }

    public void setModel(Integer model) {
        this.model = model;
    }

    public String getBucketName() {
        return bucketName;
    }

    public void setBucketName(String bucketName) {
        this.bucketName = bucketName;
    }

    public Integer getAcl() {
        return acl;
    }

    public void setAcl(Integer acl) {
        this.acl = acl;
    }

    public MultiValueMap<String, String> queryParams() {
        MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<>();
        if (model != null) {
            queryParams.add("model", model.toString());
        }
        if (bucketName != null) {
            queryParams.add("bucketName", bucketName);
        }
        if (acl != null) {
            queryParams.add("acl", acl.toString());
        }
        return queryParams;
    }
}
